import styles from './index.module.scss'
import { useState } from 'react'
import SignIn from './sign-in'
import EnterPwd from './enter_pwd'
import ResetPwd from './reset_pwd'
import ResetVerify from './reset_verify'

const Index = ({ back,email,setEmail,initType,toSuccess,setLogin }) => {
  const [domType, setDomType] = useState(initType)
  const [code, setCode] = useState('') // code，有共用
  const DOM_TYPE = {
    sign_in: SignIn, // 注册
    enter_pwd: EnterPwd, //输入密码登录
    reset_pwd: ResetPwd, // 重设密码
    reset_verify: ResetVerify, //重设验证
  }
  const Component = DOM_TYPE[domType]

  return (
    <>
      <div className={styles.loginBox}>
        <Component
          setType={setDomType}
          email={email}
          setEmail={setEmail}
          code={code}
          back={back}
          setCode={setCode}
          setLogin={setLogin}
          toSuccess={toSuccess}
        />
      </div>
    </>
  )
}

export default Index
